package com.ruoyi.shopping.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shopping.mapper.MallAttributeMapper;
import com.ruoyi.shopping.domain.MallAttribute;
import com.ruoyi.shopping.service.IMallAttributeService;

import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;

/**
 * 商品属性Service业务层处理
 * 
 * @author cws
 * @date 2024-11-19
 */
@Service
public class MallAttributeServiceImpl implements IMallAttributeService 
{
    @Autowired
    private MallAttributeMapper mallAttributeMapper;

    /**
     * 查询商品属性
     * 
     * @param id 商品属性主键
     * @return 商品属性
     */
    @Override
    public MallAttribute selectMallAttributeById(Long id)
    {
        return mallAttributeMapper.selectMallAttributeById(id);
    }

    /**
     * 查询商品属性列表
     * 
     * @param mallAttribute 商品属性
     * @return 商品属性
     */
    @Override
    public List<MallAttribute> selectMallAttributeList(MallAttribute mallAttribute)
    {
        return mallAttributeMapper.selectMallAttributeList(mallAttribute);
    }

    /**
     * 新增商品属性
     * 
     * @param mallAttribute 商品属性
     * @return 结果
     */
    @Override
    public int insertMallAttribute(MallAttribute mallAttribute)
    {
        mallAttribute.setCreateBy(getLoginUser().getUsername());
        mallAttribute.setCreateTime(DateUtils.getNowDate());
        return mallAttributeMapper.insertMallAttribute(mallAttribute);
    }

    /**
     * 修改商品属性
     * 
     * @param mallAttribute 商品属性
     * @return 结果
     */
    @Override
    public int updateMallAttribute(MallAttribute mallAttribute)
    {
        mallAttribute.setUpdateTime(DateUtils.getNowDate());
        return mallAttributeMapper.updateMallAttribute(mallAttribute);
    }

    /**
     * 批量删除商品属性
     * 
     * @param ids 需要删除的商品属性主键
     * @return 结果
     */
    @Override
    public int deleteMallAttributeByIds(Long[] ids)
    {
        return mallAttributeMapper.deleteMallAttributeByIds(ids);
    }

    /**
     * 删除商品属性信息
     * 
     * @param id 商品属性主键
     * @return 结果
     */
    @Override
    public int deleteMallAttributeById(Long id)
    {
        return mallAttributeMapper.deleteMallAttributeById(id);
    }

    @Override
    public List<String> getAllAttributeName() {
        return mallAttributeMapper.getAllAttributeName();
    }
}
